package com.joysuch.wwyt.mh.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.mh.bean.MhMajorHazardTaskRecordItemSearchBean;
import com.joysuch.wwyt.mh.bean.MhMajorHazardTaskRecordSearchBean;
import com.joysuch.wwyt.mh.bean.vo.MhMajorHazardTaskRecordGetVO;
import com.joysuch.wwyt.mh.bean.vo.MhMajorHazardTaskRecordItemVO;
import com.joysuch.wwyt.mh.bean.vo.MhMajorHazardTaskRecordVO;
import com.joysuch.wwyt.mh.service.MhMajorHazardTaskRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zqw
 * @since 2022-05-24
 */
@RestController
@RequestMapping("/mh/mh-major-hazard-task-record")
@Api(tags = "包保责任制-履职记录")
@CrossOrigin
public class MhMajorHazardTaskRecordController {
    @Autowired
    private MhMajorHazardTaskRecordService mhMajorHazardTaskRecordService;


    @PostMapping("/page")
    @ApiOperation(value = "履职记录分页查询")
    public ResultBean page(@RequestBody MhMajorHazardTaskRecordSearchBean mhMajorHazardTaskRecordSearchBean){
        Page<MhMajorHazardTaskRecordVO> page = mhMajorHazardTaskRecordService.page(mhMajorHazardTaskRecordSearchBean);
        return ResultBean.pageData(page.getRecords(),page.getTotal());

    }

    @GetMapping("/get")
    @ApiOperation(value = "履职记录单点查询")
    public ResultBean get(Long id){
        MhMajorHazardTaskRecordGetVO getVo = mhMajorHazardTaskRecordService.get(id);
        return ResultBean.success(getVo);
    }

    @GetMapping("/getItem")
    @ApiOperation(value = "履职记录表单分页查询")
    @RequiresPermissions("mh:mh-major-hazard-task-record:getItem")
    public ResultBean getItem(MhMajorHazardTaskRecordItemSearchBean mhMajorHazardTaskRecordItemSearchBean){
        Page<MhMajorHazardTaskRecordItemVO> getItemVo = mhMajorHazardTaskRecordService.getItem(mhMajorHazardTaskRecordItemSearchBean);
        return ResultBean.pageData(getItemVo.getRecords(),getItemVo.getTotal());
    }


    @GetMapping("/delete")
    @ApiOperation("删除")
    @RequiresPermissions("mh:mh-major-hazard-task-record:delete")
    public ResultBean deleteById(Long id) {
        mhMajorHazardTaskRecordService.deleteById(id);
        return ResultBean.success("");
    }
}

